//
//  RW_PlayerViewModel.m
//  SleepApp
//
//  Created by MAC on 2021/4/8.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_PlayerViewModel.h"
#import "RW_PlayerItemCollectionViewCell.h"
#import "RW_SongModel.h"
@implementation RW_PlayerViewModel

#pragma mark -- 视图模型获取
/** 获取视图模型 */
-(void)getView:(NSArray *)song_model_list
       success:(void(^)(NSArray<WLBaseCollectionViewLayerSection *> *response))success{
    if (success){
        success([self getSongListSection:song_model_list]);
    }
}

#pragma mark -- 视图模型生成
/** 生成收藏歌单列表视图 */
-(NSArray<WLBaseCollectionViewLayerSection *> *)getSongListSection:(NSArray*)singleList{
    NSMutableArray *array = [NSMutableArray array];
    
    WLBaseCollectionViewLayerSection *section = [[WLBaseCollectionViewLayerSection alloc]init];
    section.horizontalMaxWidth = Main_Screen_Width;
    
    section.insetForSection = UIEdgeInsetsMake(0, 0, 0, 0);
    section.horizontalSection = 0;
    section.horizontalCount = 1;
    section.verticalSection = 0;
    CGSize itemSize = [section getCellSizeHeight:Main_Screen_Height];

    
    for (id obj in singleList) {
        RW_PlayerItemCollectionViewCellModel *model = [[RW_PlayerItemCollectionViewCellModel alloc]init];
        if ([obj isKindOfClass:RW_SongModel.class]){
            model.song_model = obj;
        } else if ([obj isKindOfClass:RW_UserSongModel.class]){
            model.user_song_model = obj;
        }
        [section.item addObject:[RW_PlayerItemCollectionViewCell getRow:model
                                                         cellSize:itemSize]];
    }
    [array addObject:section];
    return array;
}
@end
